/**
 * FileFind - ftp/shares indexing and search php engine
 * Module: agent-java
 * Description: Agent written in java language
 * Copyright (c) 2003-2010 Rage Steel, www.gt2.ru
 */
package ru.ffind.agent.model;

import ru.ffind.common.model.AbstractEntry;
import ru.ffind.common.model.Entry;
import ru.ffind.common.model.Directory;
import java.util.Date;

import com.google.common.collect.ImmutableList;

/**
 * Implementation of directory interface for the root directory
 *
 * @author Rage Steel
 */
public class RootDirectory extends AbstractEntry implements Directory {

	public final static String ROOT_NAME = "/";
	
	private final ImmutableList<Entry> fileList;
	
    /**
     * {@inheritDoc}
     */
	@Override
	public long getCount() {
		return fileList.size();
	}

    /**
     * {@inheritDoc}
     */
	@Override
	public Date getDatetime() {
		return null;
	}

    /**
     * {@inheritDoc}
     */
	@Override
	public String getName() {
		return ROOT_NAME;
	}

    /**
     * {@inheritDoc}
     */
	@Override
	public boolean isError() {
		return false;
	}

    /**
     * Private constructor, use create factory.
     */
	private RootDirectory(ImmutableList<Entry> fileList) {
		super();
		this.fileList = fileList;
	}
	
    /**
     * Create root directory object.
     */
	public static RootDirectory create(ImmutableList<Entry> fileList) {
		return new RootDirectory(fileList);
	}

    /**
     * {@inheritDoc}
     */
	@Override
	public ImmutableList<Entry> getEntries() {
		return fileList;
	}

}
